const express = require('express')
const app = express()
const port = 8000

const next_ = require('next');
const app_ = next_({ dev: false })
const handle_ = app_.getRequestHandler();

const path = require('path');
app.use(express.static(path.join(__dirname, 'public')));

// app.get('/', (req, res) => res.send('Hello World!'))
app.all('/*', function (req, res, next) {
    console.log(req.url);
    if (req.url.indexOf('_next') > -1) {
        return handle_(req, res);
    } else {
        next();
    }
	

});
app.get('/', function (req, res, next) {
    app_.render(req, res, '/index', req.query);
});

app.get('/about', function (req, res, next) {
    app_.render(req, res, '/about', req.query);
});

app.listen(port, () => console.log(`Example app listening on port ${port}!`))